<?php
/**
 * @package pmapi
 * @copyright Copyright (c)2014 Enrico Fagnoni
 * @license GNU General Public License version 3, or later
 *
 * @since 1.0.0
 */
 
defined('_JEXEC') or die;
 
// import Joomla modelitem library
jimport('joomla.application.component.modellist');
if (!class_exists('DatasetModel')) require ( JPATH_COMPONENT.DS.'models'.DS.'dataset.php');

 
class PmapiModelProducts extends DatasetModel
{
    /**
     * Get the master query for retrieving a list of products.
     * N.B. It is non guarantee that all listed products will be accessible from the user.
     * But if you try to get a product datadump  that you can't access, you'll get a 401 error (unauthorized)
     * In other word you can list all products it but you can get only authorized ones.
     * This because checking permissions at this level should be resource intensive.
     */
    function getListQuery()
    { 
        return  $this->getDbo()
            ->getQuery(true)
            ->select('virtuemart_product_id')
            ->from( '#__virtuemart_products' )
            ->where( 'published = 1');
    }         
}